package com.xiaojian.accountserver.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xiaojian.accountserver.Mapper.adminMapper;
import com.xiaojian.accountserver.pojo.Admin;
import com.xiaojian.userserver.mapper.userMapper;
import com.xiaojian.userserver.pojo.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RequestMapping("/account")
@RestController
public class AccountController {

    @GetMapping("/login")
    public Object login(@RequestParam String type, @RequestParam String username, @RequestParam String password) {
        Object object = null;
        switch (type) {
            case "user":
                QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
                userQueryWrapper.eq("username", username);
                userQueryWrapper.eq("password", password);
//                object = userMapper.selectOne(userQueryWrapper);
                break;
            case "admin":
                QueryWrapper<Admin> adminQueryWrapper = new QueryWrapper<>();
                adminQueryWrapper.eq("username", username);
                adminQueryWrapper.eq("password", password);
//                object = adminMapper.selectOne(adminQueryWrapper);
                break;
        }
       /* if (object == null) {
            throw new RuntimeException("用户名或密码错误");
        }*/
        return object;
    }
}
